<?php
/**
 * 协程
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/22 0022
 * Time: 15:32
 */
$http = new swoole_http_server('0.0.0.0', 8811);

$http->on('request', function($request, $response){
    //开启协程redis
    $redis = new Swoole\Coroutine\Redis();
    $redis->connect('127.0.0.1', 6379);
    $value = $redis->get($request->get['foo']);

    $response->header("Content-Type", "text/plain");
    $response->end($value);
});

$http->start();

















